#include "calc_system.hpp"

int CalcDamage(CreatureProperties& p1, CreatureProperties& p2, DmgState& state){
    const int dmg_max_bound = 20;
    int n = D(dmg_max_bound);
    int s = p1.attack_+n;
    state = DmgState::NORMAL;
    int damage = p1.strength_; //FIXME 这里武器的伤害没有加上，因为暂时还没有做武器
    if(s>p2.defence_){
        if(n==dmg_max_bound){
            damage = 2*damage;
            state = DmgState::CRITICAL_ATTACK; 
        }else if(n==1){
            damage = 0;
            state = DmgState::CRITICAL_FAULT;
        }
    }else
        damage = 0;
    return damage;
}
